<?php include('view/template/common/header.tpl'); ?>

<script type="text/javascript">
function BrowseServer()
{
// You can use the "CKFinder" class to render CKFinder in a page:
var finder = new CKFinder();
finder.basePath = './view/javascript/ckfinder/'; // The path for the installation of CKFinder (default = "/ckfinder/").
finder.selectActionFunction = SetFileField;
finder.popup();

}
// This is a sample function which is called when a file is selected in CKFinder.
function SetFileField( fileUrl )
{
document.getElementById( 'xFilePath' ).value = fileUrl;
}
</script>

<?php if ($error_warning) { ?>
<div class="warning"><?php echo $error_warning; ?></div>
<?php } ?>
<div class="box">
   <div class="left"></div>
   <div class="right"></div>
  <div class="heading">
    <h1 style="background-image: url('./view/image/country.png');"><?php echo $heading_title; ?></h1>
    <div class="buttons">
	<a onclick="$('#form').submit();" class="button"><span><?php echo "Lưu Lại"; ?></span></a>
	<a onclick="location = '<?php echo $link_list; ?>';" class="button"><span><?php echo "Hủy"; ?></span></a></div>
   </div>
	 <div class="content">
	    <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="form">
	      <table class="form">
	      <tr>
			<td>Tên tài liệu</td>
	        	<td><input  type="text" name="ten_giao_an" value="<?php echo $giaoan['ten_giao_an']; ?>" size="60"/></td>
	  	</tr>
       
        <tr>
		<td>Tác giả</td>
                <td><input  type="text" name="tac_gia" value="<?php echo $giaoan['tac_gia']; ?>"/>	</td>
       </tr>
       <tr>
		<td>Dung lượng</td>
                <td><input  type="text" name="dung_luong" value="<?php echo $giaoan['dung_luong']; ?>"/>	</td>
       </tr>
	       <!--
                <tr>
			<td>Đính kèm</td>
			<td><input type="file" name="file"/></td>
		</tr>
               -->

                 <tr>
                 <td>Đính kèm</td>
                 <td>
		<input id="xFilePath" name="file" type="text" size="60" value="<?php echo $giaoan['file']; ?>" />
		<input type="button" value="Chọn từ máy" onclick="BrowseServer();" />
                </td>
                </tr>




         <tr>
	 	<td>Liên kết</td>
                <td><input  type="text" name="link" value="<?php echo $giaoan['link']; ?>" size="60"/> (Từ web khác, bắt đầu = http://)</td>
         </tr>
            
          <tr>
		  <td>Khối học</td>
           <td>
               <select name="khoi_hoc_id">
               <option value ="1"> Chung</option>
               <?php if($list_khoihoc) {?>
               <?php foreach ($list_khoihoc as $khoihoc) {?>
               <?php if ($giaoan['khoi_hoc_id'] == $khoihoc['khoi_hoc_id']) {?>
                <option value ="<?php echo $khoihoc['khoi_hoc_id']; ?>" selected="selected"> <?php echo $khoihoc['ten_khoi_hoc']; ?>  </option>
               <?php } else {?>
               <option value ="<?php echo $khoihoc['khoi_hoc_id']; ?>"> <?php echo $khoihoc['ten_khoi_hoc']; ?>  </option>
               <?php }} ?>
               <?php }?>
               </select>
           </td>
          </tr>
           
          <tr>
		  <td>Nhóm giáo án</td>
             <td>  <select name="nhom_giao_an_id">
               <option value="1"> Chung</option>
               <?php if($list_nhomgiaoan) {?>
               <?php foreach ($list_nhomgiaoan as $nhomgiaoan) {?>
               <?php if ($giaoan['nhom_giao_an_id'] == $nhomgiaoan['nhom_giao_an_id']) {?>
                <option value="<?php echo $nhomgiaoan['nhom_giao_an_id']; ?>" selected="selected"> <?php echo $nhomgiaoan['ten_nhom_giao_an']; ?>  </option>
               <?php } else {?>
               <option value ="<?php echo $nhomgiaoan['nhom_giao_an_id']; ?>"> <?php echo $nhomgiaoan['ten_nhom_giao_an']; ?>  </option>
               <?php } ?>
               <?php } ?>
               <?php }?>
               </select>
   	      </td>
          </tr>
           
	        <tr>
			<td><?php echo $motachung;?></td>
			<td><textarea name="mo_ta_chung" id="motachung"><?php echo $giaoan['general']; ?></textarea></td>
	        </tr>
	        <tr>
	        	<td><?php echo $motachitiet;?></td>
	     		<td><textarea name="mo_ta_chi_tiet" id="motachitiet"><?php echo $giaoan['detail']; ?></textarea></td>
	        </tr>
	      </table>
	    </form>
	  </div>

	<div class="bottom_button">
		<a onclick="$('#form').submit();" class="button"><span><?php echo "Lưu Lại"; ?></span></a>
		<a onclick="location = '<?php echo $link_list; ?>';" class="button"><span><?php echo "Hủy"; ?></span></a>
	</div>
</div>
<?php include('view/template/common/footer.tpl'); ?>
<script type="text/javascript">
	 var editor = CKEDITOR.replace( 'motachitiet');
         var editor1 = CKEDITOR.replace( 'motachung',{
					toolbar :
					[
						[ 'Bold', 'Italic', '-', 'NumberedList', 'BulletedList', '-', 'Link', 'Unlink','-','Image' ],
						[ 'UIColor' ], ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock','-','BidiLtr','BidiRtl']
					]});
	 CKFinder.setupCKEditor( editor, './view/javascript/ckfinder/' ) ;
         CKFinder.setupCKEditor( editor1, './view/javascript/ckfinder/' ) ;
</script>
